package com.github.maojx0630.onebot.dto.send.msg;

import com.github.maojx0630.onebot.dto.send.Send;

public class SendImage implements Send {

  private final String type;

  private final String path;

  public SendImage(String type, String path) {
    this.type = type;
    this.path = path;
  }

  public static SendImage ofNameOrUrl(String path) {
    return new SendImage("", path);
  }

  public static SendImage ofBase64(String path) {
    return new SendImage("base64", path);
  }

  public static SendImage ofPath(String path) {
    return new SendImage("path", path);
  }

  @Override
  public String getKey() {
    return "file";
  }

  @Override
  public String getType() {
    return "image";
  }

  /**
   * file 文件路径<br>
   * url 网络图片url<br>
   * base64 base64编码的图片<br>
   */
  @Override
  public String getValue() {
    return switch (this.type) {
      case "base64" -> "base64://" + path;
      case "path" -> "file:///" + path;
      default -> path;
    };
  }
}
